From: Tim Starling Date: Wed, 7 May 2008 06:42:16 +0000 (+0000) Subject: * Rename wfGetAvailableRights() to User::getAllRights() X-Git-Tag: 1.31.0-rc.0~47850 X-Git-Url: http://git.cyclocoop.org/%7D%7Cconcat%7B?a=commitdiff_plain;h=451e87a875576a3f7711146ce9481b597c533d95;p=lhc%2Fweb%2Fwiklou.git * Rename wfGetAvailableRights() to User::getAllRights() * Reintroduce $wgAvailableRights so that the above function is not so terribly slow and broken --- diff --git a/includes/DefaultSettings.php b/includes/DefaultSettings.php index 4ac2eb22ec..281e51168e 100644 --- a/includes/DefaultSettings.php +++ b/includes/DefaultSettings.php @@ -1282,6 +1282,13 @@ $wgAutopromote = array( */ $wgAddGroups = $wgRemoveGroups = array(); + +/** + * A list of available rights, in addition to the ones defined by the core. + * For extensions only. + */ +$wgAvailableRights = array(); + /** * Optional to restrict deletion of pages with higher revision counts * to users with the 'bigdelete' permission. (Default given to sysops.) diff --git a/includes/Defines.php b/includes/Defines.php index 9ef22cb717..b0275ec234 100644 --- a/includes/Defines.php +++ b/includes/Defines.php @@ -84,30 +84,6 @@ define( 'MW_MATH_MODERN', 4 ); define( 'MW_MATH_MATHML', 5 ); /**#@-*/ -/** - * User rights list - * @deprecated - */ -$wgAvailableRights = array( - 'block', - 'bot', - 'createaccount', - 'delete', - 'edit', - 'editinterface', - 'import', - 'importupload', - 'move', - 'patrol', - 'protect', - 'read', - 'rollback', - 'siteadmin', - 'unwatchedpages', - 'upload', - 'userrights', -); - /**#@+ * Cache type */ diff --git a/includes/GlobalFunctions.php b/includes/GlobalFunctions.php index 27b5a5d396..07cfdf6cc6 100644 --- a/includes/GlobalFunctions.php +++ b/includes/GlobalFunctions.php @@ -2608,23 +2608,3 @@ function wfWaitForSlaves( $maxLag ) { return md5( mt_rand( 0, 0x7fffffff ) . $salt ); } - -/** - * Generate a list of all available rights. - * @todo Doesn't list any rights which aren't assigned to a group. - */ -function wfGetAvailableRights() { - global $wgGroupPermissions; - - $rights = array(); - - foreach( $wgGroupPermissions as $permissions ) { - $rights = array_merge( array_keys($permissions),$rights ); - } - - $rights = array_unique($rights); - - wfRunHooks( 'GetAvailableRights', array( &$rights ) ); - - return $rights; -} diff --git a/includes/User.php b/includes/User.php index 103b91167d..464966c997 100644 --- a/includes/User.php +++ b/includes/User.php @@ -105,6 +105,52 @@ class User { 'mGroups', ); + /** + * Core rights + * Each of these should have a corresponding message of the form "right-$right" + */ + static $mCoreRights = array( + 'apihighlimits', + 'autoconfirmed', + 'autopatrol', + 'bigdelete', + 'block', + 'blockemail', + 'bot', + 'browsearchive', + 'createaccount', + 'createpage', + 'createtalk', + 'delete', + 'deletedhistory', + 'edit', + 'editinterface', + 'editusercssjs', + 'import', + 'importupload', + 'ipblock-exempt', + 'markbotedits', + 'minoredit', + 'move', + 'nominornewtalk', + 'patrol', + 'protect', + 'proxyunbannable', + 'purge', + 'read', + 'reupload', + 'reupload-shared', + 'rollback', + 'suppressredirect', + 'trackback', + 'undelete', + 'unwatchedpages', + 'upload', + 'upload_by_url', + 'userrights', + ); + static $mAllRights = false; + /** * The cache variable declarations */ @@ -2716,6 +2762,22 @@ class User { ); } + /** + * Get a list of all available permissions + */ + static function getAllRights() { + if ( self::$mAllRights === false ) { + global $wgAvailableRights; + if ( count( $wgAvailableRights ) ) { + self::$mAllRights = array_unique( array_merge( self::$mCoreRights, $wgAvailableRights ) ); + } else { + self::$mAllRights = self::$mCoreRights; + } + wfRunHooks( 'UserGetAllRights', array( &self::$mAllRights ) ); + } + return self::$mAllRights; + } + /** * Get a list of implicit groups *